objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++) {
    objects[i].outerHTML = objects[i].outerHTML;
}

function showDateEN() {
    var dt = new Date();
    var strMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "Octorber", "November", "December");
    var strDay = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
    var date = strDay[dt.getDay()] + ", ";
    var years = dt.getYear();
    if (years < 1900) years += 1900;
    return (date += strMonth[dt.getMonth()] + '-' + dt.getDate() + '-' + years);
}
function showDateVN() {
    var dt = new Date();
    var strMonth = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
    var strDay = new Array("Chủ Nhật", "Thứ Hai", "Thứ Ba", "Thứ Tư", "Thứ Năm", "Thứ Sáu", "Thứ Bảy");
    var date = strDay[dt.getDay()] + ", ";
    var years = dt.getYear();
    if (years < 1900) years += 1900;
    return (date += "ngày " + dt.getDate() + " tháng  " + strMonth[dt.getMonth()] + " năm " + years);
}


/* Highlight */
var jq = jQuery.noConflict();
if (typeof cssQuery == 'undefined') {
    function cssQuery(s, f) {
        return jq.makeArray(jq(s, f))
    }
}
function getContentArea() {
    var node = jq('#region-content,#content');
    return node.length ? node[0] : null
}
function highlightTermInNode(node, word) {
    var contents = node.nodeValue;
    if (jq(node).parent().hasClass("highlightedSearchTerm")) return;
    var highlight = function (content) {
        return jq('<span class="highlightedSearchTerm">' + content + '</span>')
    };
    while (contents && (index = contents.toLowerCase().indexOf(word)) > -1) {
        jq(node).before(document.createTextNode(contents.substr(0, index))).before(highlight(contents.substr(index, word.length))).before(document.createTextNode(contents.substr(index + word.length)));
        var next = node.previousSibling;
        jq(node).remove();
        node = next;
        contents = node.nodeValue
    }
}
function highlightSearchTerms(terms, startnode) {
    if (!terms || !startnode) return;
    jq.each(terms, function (i, term) {
        term = term.toLowerCase();
        if (!term || /(not|and|or)/.test(term)) return;
        jq(startnode).find('*').andSelf().contents().each(function () {
            if (this.nodeType == 3) highlightTermInNode(this, term)
        })
    })
}
function getSearchTermsFromURI(uri) {
    var query;
    if (typeof decodeURI != 'undefined') {
        query = decodeURI(uri)
    } else if (typeof unescape != 'undefined') {
        query = unescape(uri)
    } else {
    }
    var result = new Array();
    if (window.decodeReferrer) {
        var referrerSearch = decodeReferrer();
        if (null != referrerSearch && referrerSearch.length > 0) {
            result = referrerSearch
        }
    }
    var qfinder = new RegExp("(searchterm|SearchableText)=([^&]*)", "gi");
    var qq = qfinder.exec(query);
    if (qq && qq[2]) {
        var terms = qq[2].replace(/\+/g, ' ').split(' ');
        result.push.apply(result, jq.grep(terms, function (a) {
            return a != ""
        }));
        return result
    }
    return result.length == 0 ? false : result
}

jq(function () {
    var terms = getSearchTermsFromURI(window.location.search);
    highlightSearchTerms(terms, getContentArea())
});
/* END - Highlight */